<?php

namespace app\mobile\controller;

use think\Controller;

use app\store\model\store\Shop as ShopModel;
use think\Db;

class Test extends Controller
{
    public function test()
    {
		$model = new ShopModel;
		$list = $model->getList($this->request->get());
		return $this->fetch('test', compact('list'));
    }
	public function createmenu(){
		// $data ='{"button":[
		// 	{"type":"view","name":"岚皋信息","url":"http://gg.dieyaloft.com/index.php?rand=11"},
		// 	{"type":"view","name":"免费发布","url":"http://gg.dieyaloft.com/appMsg/zlMsgQita.php?act=zhizuozixun&rand=33"},
		// 	{"type":"click","name":"推广赚钱","key":"tuiguangzhuangqian"}
		// 	]}';
		$data ='{"button":[
			{"type":"view","name":"筛查订单","url":"https://ystmall.dieya.net/index.php?s=/mobile/perpage/orderdes"}
		]}';
		$weixin = new \wechatFun(Config('appId'), Config('appSecret'));
		var_dump($weixin->create_menu($data));
	}
	public function delmenu(){
		$weixin = new \wechatFun(Config('appId'), Config('appSecret'));
		var_dump($weixin->delete_menu());
	}

    /** 初始化表单提交界面 */
    public function formPage(){
        return $this->fetch('test/formpage');
    }
    public function indbAjax(){
        $paramArr = $this->request->param();
        $formObj = isset($paramArr['formObj']) ? $paramArr['formObj'] : "";
        //ddd($formObj);
        $shopId = 10020;
        $inArr['dl_shopid'] = $shopId;
        $inArr['dl_shopname'] = "能动乐学大学城校区";
        $inArr['dl_activetitle'] = "手动添加";
        $inArr['dl_dituiname'] = '开班信息收集';
        $inArr['wxapp_id'] = 10016;
        $inArr['du_mobile'] = $formObj['mobile_ma'];
        $inArr['du_mobile2'] = $formObj['mobile_ba'];
        $inArr['du_truename'] = $formObj['name'];
        $inArr['du_sex'] = $formObj['sex'];
        $inArr['du_school'] = $formObj['school'];
        $inArr['du_grade'] = $formObj['grade'];
        $inArr['du_flowid'] = 80;
        $inArr['du_class'] = $formObj['ndclass'];
        $inArr['du_english'] = $formObj['english'];
        $inArr['du_hopestr'] = implode('@@@', $formObj['hope']);
        $inArr['dl_addtime'] = date('Y-m-d H:i:s',time());
        //ddd($inArr);

        $back['state'] = 'addOk';
        $userObj = Db::name('ditui_user')->where(['du_mobile'=>$formObj['mobile_ma'], 'dl_shopid'=>$shopId])->find();
        if($userObj){
            $back['msg'] = '信息已提交，请勿重复提交！！！';
            Db::name('ditui_user')->where('dl_id',$userObj['dl_id'])->update($inArr);
        }
        else{
            $back['msg'] = '提交成功！！！';
            Db::name('ditui_user')->insert($inArr);
        }

        return ajaxSuccessObj($back, '添加修改成功');
    }
}